package com.factory.jdkcode;

import java.util.Calendar;

/**
 * @author 薛虎
 * @date 2020/12/24 10:37
 * JDK简单工厂模式代码分析
 */
public class Factory {
    public static void main(String[] args) {
        //getInstance是Calendar静态方法
        Calendar calendar = Calendar.getInstance();
        //注意月份下标从0开始,所以取月份要+1
        System.out.println("年:" + calendar.get(Calendar.YEAR));
        System.out.println("月:" + calendar.get(Calendar.MONTH) + 1);
        System.out.println("日:" + calendar.get(Calendar.DAY_OF_MONTH));
        System.out.println("时:" + calendar.get(Calendar.HOUR_OF_DAY));
        System.out.println("分:" + calendar.get(Calendar.MINUTE));
        System.out.println("秒:" + calendar.get(Calendar.SECOND));
    }
}
